package com.ld.control.business.robot.controller;


import com.ld.control.business.customer.vo.req.CustomerReqVo;
import com.ld.control.business.customer.vo.reqsp.CustomerRespVo;
import com.ld.control.business.robot.service.RobotPointService;
import com.ld.control.business.robot.vo.req.RobotPointReqVo;
import com.ld.control.business.robot.vo.resp.RobotPointRespVo;
import com.ld.control.common.PrimaryKeyReqVo;
import com.ld.control.common.ResultResponse;
import com.ld.control.common.vo.GeneratePageListVo;
import com.ld.control.sysenum.ResultResponseEnum;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 机械臂点位信息 前端控制器
 * </p>
 *
 * @author wangfeng
 * @since 2024-07-08
 */
@Slf4j
@Tag(name = "机械臂点位相关接口")
@RestController
public class RobotPointController {


    @Autowired
    private RobotPointService robotPointService;

    @GetMapping("/api/centralControl/robotPoint/getPageList")
    @Operation(summary = "查询机械臂点位列表")
    public ResultResponse<GeneratePageListVo<RobotPointRespVo>> getPageList(
            @Parameter(description = "区域列表的主键id") @RequestParam(required = false) Long regionId,
            @Parameter(description = "点位名称") @RequestParam(required = false) String name,
            @Parameter(description = "点位分类：0单点位，1组合点位") @RequestParam(required = false) Integer type,
            @Parameter(description = "点位变量") @RequestParam(required = false) String targetPoint,
            @Parameter(description = "安全点位变量") @RequestParam(required = false) String initPoint,
            @Parameter(description = "当前页")@RequestParam(required = false, defaultValue = "1") Integer current,
            @Parameter(description = "页大小")@RequestParam(required = false, defaultValue = "10") Integer size
    ) {
        GeneratePageListVo<RobotPointRespVo> customerServicePageList = robotPointService.getPageList(regionId, name, type, targetPoint, initPoint, current, size);
        return ResultResponse.success(customerServicePageList);
    }

    @GetMapping("/api/centralControl/robotPoint/getById")
    @Operation(summary = "查询详情")
    public ResultResponse<RobotPointRespVo> getById(
            @RequestParam Long id
    ) {
        return ResultResponse.success(robotPointService.getById(id));
    }

    @PostMapping("/api/centralControl/robotPoint/add")
    @Operation(summary = "新增机械臂点位")
    public ResultResponse<ResultResponseEnum> add(
            @RequestBody RobotPointReqVo reqVo
    ) {
        robotPointService.add(reqVo);
        return ResultResponse.success();
    }

    @PostMapping("/api/centralControl/robotPoint/update")
    @Operation(summary = "修改机械臂点位")
    public ResultResponse<ResultResponseEnum> update(
            @RequestBody RobotPointReqVo reqVo
    ) {
        robotPointService.update(reqVo);
        return ResultResponse.success();
    }

    @PostMapping("/api/centralControl/robotPoint/deleteById")
    @Operation(summary = "删除机械臂点位")
    public ResultResponse<ResultResponseEnum> deleteById(
            @RequestBody PrimaryKeyReqVo reqVo
    ) {
        robotPointService.delete(reqVo.getId());
        return ResultResponse.success();
    }

}

